import request from '@/utils/request'

export function list (data) {
  data.json = true
  const url = '/dic/type/list'
  return request.post(url, data)
}

export function all () {
  const url = '/dic/type/all'
  return request.get(url)
}

export function down (data) {
  data.json = true
  const config = {
    responseType: 'arraybuffer'
  }
  const url = '/dic/type/down'
  return request.post(url, data, config)
}

export function info (id) {
  const url = '/dic/type/info/' + id
  return request.get(url)
}

export function save (data) {
  data.json = true
  const url = '/dic/type/save'
  return request.post(url, data)
}

export function update (data) {
  data.json = true
  const url = '/dic/type/update'
  return request.post(url, data)
}

export function remove (data) {
  const url = '/dic/type/delete'
  return request.post(url, data)
}

export function options () {
  const url = '/dic/type/dmz/options'
  return request.get(url)
}

export function upload (file) {
  const url = '/dic/type/upload'
  const forms = new FormData()
  forms.append('file', file)
  const config = {
    headers: { 'Content-Type': 'multipart/form-data' }
  } //
  return request.post(url, forms, config)
}
